import React from "react";
import { createBrowserRouter } from "react-router-dom";
import ErrorPage from "@/pages/404/";
import Home from "@/pages/home/";
import Auth from "@/components/auth";

const router = createBrowserRouter([
  {
    path: "/",
    errorElement: <ErrorPage />,
    async lazy() {
      const { default: App } = await import("@/App");
      return { Component: App };
    },
    children: [
      {
        errorElement: <ErrorPage />,
        children: [
          {
            index: true,
            async lazy() {
              const { default: Home } = await import("@/pages/home/");
              return { Component: Home };
            }
          },
          {
            path: "collapse",
            async lazy() {
              const { default: Collapse } = await import("@/pages/collapse/");
              return { Component: Collapse };
            },
          },
          {
            path: "timeline",
            async lazy() {
              const { default: Timeline } = await import("@/pages/timeline/");
              return { Component: Timeline };
            },
          },
          {
            path: "app",
            async lazy() {
              const { default: Application } = await import(
                "@/pages/application/"
              );
              return { Component: Application };
            },
          },
        ],
      },
    ],
  },
  {
    path: "/login",
    async lazy() {
      const { default: Admin } = await import("@/pages/login/");
      return { Component: Admin };
    },
  },
]);

export default router;
